package acm.蓝桥杯二分前缀;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * 当距离为n时，需要移走多少个瓶盖
 */
public class 丢瓶盖 {
    static int[] nums;
    static int m;

    public static void main(String[] args) {
        Reader sc = new Reader();
        int n = sc.nextInt();
        nums = new int[n];
        m = n - sc.nextInt();
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        System.out.println(binarySearch());
    }

    /**
     * 找到最大的d，使得当距离为d时，能移走m个瓶盖
     *
     * @return
     */
    public static int binarySearch() {
        int l = 1, r = nums[nums.length - 1] - nums[0];
        while (l <= r) {    //当 l > r 时， r是被校验过的最后一个符合条件的值
            int mid = l + ((r - l) >> 1);
            if (check(mid)) {
                l=mid+1;
            } else {
                r=mid-1;
            }
        }
        return r;
    }

    /**
     * 当距离为d时，是否能移走m个瓶盖
     */
    public static boolean check(int d) {
        int count = 0;
        int l = 0, r = 1;
        while (r < nums.length) {
            if (nums[r] - nums[l] < d) {
                count++;
                r++;
            } else {
                l = r;
                r++;
            }
        }
        return count <= m;
    }
    static class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }
        public void clear(){
            tokenizer = new StringTokenizer("");
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
//    public BigInteger nextBigInt() {
//        return new BigInteger(next());
//    }
    }

}
